<?php

/**
 * Project filter form base class.
 *
 * @package    cmsot
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterBaseTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
abstract class BaseFormFilterDoctrine extends sfFormFilterDoctrine {

    public function setup() {

        foreach ($this->getWidgetSchema()->getFields() as $field => $widget) {
            
//            if ($widget instanceof sfWidgetFormDoctrineChoice && in_array($field, array('pov_id', 'product_option_value_id', 'product_id'))) {
//                $this->widgetSchema[$field] = new sfWidgetFormInputHidden();
//            }

//            if ('order_id' === $field) {
//                $this->widgetSchema[$field] = new sfWidgetFormInputText();
//            }

            if (get_class($widget) == 'sfWidgetFormFilterDate') {
                $this->widgetSchema[$field] = new sfWidgetFormFilterDate(array(
                            'from_date' => new nlWidgetFormHtml5Date(array(), array('class' => 'date_relative')),
                            'to_date' => new nlWidgetFormHtml5Date(array(), array('class' => 'date_relative')),
                            'with_empty' => false,
                            'template' => 'с <div class="form_input">%from_date%</div>по <div class="form_input">%to_date%</div>'
                        ));
            } elseif (get_class($widget) == 'sfWidgetFormFilterInput') {
                $this->widgetSchema[$field] = new sfWidgetFormFilterInput(array('with_empty' => false));
            }
        }
    }

}
